using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataAccessLayer;
using System.Collections.Generic;

public partial class MyMasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Session["type"]).ToString() == "admin")
            lnkLogin.Text = "Logged in as <b>" + Session["admin name"] + "</b>";
        else if ((Session["type"]).ToString() == "user")
        {
            lnkPostQuery.Visible = true;
            lnkViewQuery.Visible = true;
            lnkLogin.Text = "Logged in as <b><i>" + Session["user name"] + "</i></b>";
        }
        else if ((Session["type"]).ToString() == "doctor")
        {/*
            lnkPostAdvice.Visible = true;
            lnkViewAdvice.Visible = true;*/
            lnkLogin.Text = "Logged in as <b><i>" + Session["doctor name"] + "</i></b>";
        }
        else
        {
            lnkLogin.Text = "Browsing as <b>Guest</b>";
            lnkLogout.Visible = false;
        }
    }
    protected void imgbtnGoCategory_Click(object sender, ImageClickEventArgs e)
    {
        int opt = ddlCategory.SelectedIndex;
        Session["category"] = opt.ToString();

        switch (opt)
        {
            case 0: // search by disease
                Common c = new Common();
                string conn = c.fetchConnString();
                Disease ds = new Disease(conn);
                List<string> lstDDLData = new List<string>();
                DataTable dtData = ds.show();
                foreach (DataRow drRow in dtData.Rows)
                {
                    lstDDLData.Add(drRow[0].ToString());
                }
                ddlKeyword.DataSource = lstDDLData;
                ddlKeyword.DataBind();
                break;

            case 1: // search by medicine
                Common c1 = new Common();
                string conn1 = c1.fetchConnString();
                Medicine md = new Medicine(conn1);
                List<string> lstDDLData1 = new List<string>();
                DataTable dtData1 = md.mShow();
                foreach (DataRow drRow1 in dtData1.Rows)
                {
                    lstDDLData1.Add(drRow1[0].ToString());
                }
                ddlKeyword.DataSource = lstDDLData1;
                ddlKeyword.DataBind();
                break;

            case 2: // search by medical specialist
                //"select * from Diseases where Symptoms = '" & txtSearch.Text & "'"
                Common c3 = new Common();
                string conn3 = c3.fetchConnString();
                Doctor doc = new Doctor(conn3);
                List<string> lstDDLData3 = new List<string>();
                DataTable dtData3 = doc.Dshow();
                foreach (DataRow drRow1 in dtData3.Rows)
                {
                    lstDDLData3.Add(drRow1[0].ToString());
                }
                ddlKeyword.DataSource = lstDDLData3;
                ddlKeyword.DataBind();
                break;

            case 3: // search by symptoms
                Common c2 = new Common();
                string conn2 = c2.fetchConnString();
                Symptom smp = new Symptom(conn2);
                List<string> lstDDLData2 = new List<string>();
                DataTable dtData2 = smp.sShow();
                foreach (DataRow drRow1 in dtData2.Rows)
                {
                    lstDDLData2.Add(drRow1[0].ToString());
                }
                ddlKeyword.DataSource = lstDDLData2;
                ddlKeyword.DataBind();
                break;
        }
    }
    protected void imgbtnGoKeyword_Click(object sender, ImageClickEventArgs e)
    {
        Session["keyword"] = ddlKeyword.SelectedItem.Text;
        Response.Redirect("SearchResults.aspx");
    }
    protected void lnkLogin_Click(object sender, EventArgs e)
    {
        if ((Session["type"]).ToString() == "admin")
            Response.Redirect("AdminProfile.aspx");
        else if ((Session["type"]).ToString() == "user")
            Response.Redirect("UserProfile.aspx");
        else if ((Session["type"]).ToString() == "doctor")
            Response.Redirect("DoctorProfile.aspx");
        else
            Response.Redirect("Home.aspx");
    }
    protected void lnkThemes_Click(object sender, EventArgs e)
    {
        Response.Redirect("Themes.aspx");
    }
    protected void lnkSettings_Click(object sender, EventArgs e)
    {
        Response.Redirect("Settings.aspx");
    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Response.Redirect("Loading.aspx");
    }
    protected void imgbtnHome_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Home.aspx");
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //
    }
    protected void lnkAboutUs_Click(object sender, EventArgs e)
    {
        Response.Redirect("AboutUs.aspx");
    }
    protected void lnkContactUs_Click(object sender, EventArgs e)
    {
        Response.Redirect("ContactUs.aspx");
    }
    protected void lnkFeedback_Click(object sender, EventArgs e)
    {
        Response.Redirect("Feedback.aspx");
    }
    protected void LinkButton5_Click(object sender, EventArgs e)
    {
        //
    }
    protected void lnkViewQuery_Click(object sender, EventArgs e)
    {
        Response.Redirect("MedicalQuery.aspx");
    }
    protected void lnkPostQuery_Click(object sender, EventArgs e)
    {
        Response.Redirect("PostQuery.aspx");
    }
    protected void lnkViewAdvice_Click(object sender, EventArgs e)
    {
        Response.Redirect("MedicalAdvice.aspx");
    }
    protected void lnkPostAdvice_Click(object sender, EventArgs e)
    {
        Response.Redirect("PostAdvice.aspx");
    }
}
